package com.heima.kafka.controller;

import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.util.StringUtils;

public class HelloListener {
    @KafkaListener(topics = "itcast")
    public void OnMessage(ConsumerRecord<String,String> record, Consumer<String,String> consumer){
            if (!StringUtils.isEmpty(record)){
                System.out.println(record.value());
                System.out.println(record.offset());
                consumer.commitSync();
            }
    }
}
